<?php 
namespace Home\Model;
use Think\Model;
class RequirementModel extends Model{
	/*
	* 提交需求--左"r_xmId,r_contactName,r_contactPhone,r_industry,r_consultBudget,r_projectTitle,r_submitTime,r_submitId"
	*/
	public function insertIntoReqForSubmitLeft($data,$where=null,$field=null){
		$data=M("Requirement")->field($field)->where($where)->add($data);
        if($data){
            return $data;
        }else{
            return null;
        }
	}

    /*
    * 提交需求--右--根据项目id将上传的文件路径存入数据库
    */
    public function getXmIdToModUpload($data=null,$where=null){
        return M("Requirement")->where($where)->save($data);
        if($data){
            return $data;
        }else{
            return null;
        }
    }

	/*
    * 个人中心--我的项目
    */
    public function selectMyProjectInPC($where=null,$field=null){
        $data=M("Requirement")->where($where)->field($field)->select();
        // echo "<p><p><p><p><p>lastsql=".M('Requirement')->getLastSql();
        if($data){
            return $data;
        }else{
            return null;
        }
    }

    /*
    * 个人中心--我的项目数量
    */
    public function selectMyProjectNum($where=null,$field=null){
        $mod = M("Requirement");
        //子查询
        $subQuery = $mod->where($where)->order($order)->field($field)->buildSql();
        $count = $mod->table($subQuery.' a')->where("a.r_projectname != ''")->count();
        if($count == ''){
            return null;
        }
        return $count;
    }

	/*
	* 获得即将添加数据的自动编号id
	*/
	public function getNextAutoIncrementId(){
		$db=M("Requirement");
		$sql = "SHOW TABLE status";
	    $query = $db->query($sql);
	    $table=$query[0];
	    $nextid = $table['auto_increment'];
	    // if($nextid==null){
	    // 	$nextid=0;
	    // }
	    return $nextid;
	}
}